<template>
  <div class="top">
    <div class="left">
      <span class="lbtn" @click="goHome">首页</span>
    </div>
    <div class="center">智慧旅游可视化大数据平台</div>
    <div class="right">
      <span class="rbtn">统计报告</span>
      <span class="time">{{ time }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
import moment from "moment";
import { onBeforeUnmount, onMounted, ref } from "vue";

const router = useRouter();
let time = ref(moment().format("YYYY年MM月DD日 hh时mm分ss秒"));
let timer = ref();
const goHome = () => {
  router.push("/");
};
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format("YYYY年MM月DD日 hh时mm分ss秒");
  }, 1000);
});
onBeforeUnmount(() => {
  clearInterval(timer.value);
});
</script>

<style lang="scss" scoped>
.top {
  display: flex;
  width: 100%;
  height: 100%;
  //   border: 1px solid blue;
  .left {
    flex: 1;
    height: 40px;
    background: url(../../images/dataScreen-header-left-bg.png) no-repeat;
    background-size: 100% 100%;
    line-height: 50px;
    text-align: right;
    .lbtn {
      background: url(../../images/dataScreen-header-btn-bg-l.png) no-repeat;
      width: 150px;
      height: 40px;
      text-align: center;
      background-size: 100% 100%;
      display: inline-block;
      color: #29f0f6;
      font-size: 20px;
      cursor: pointer;
    }
  }
  .center {
    flex: 2;
    text-align: center;
    line-height: 80px;
    color: #29f0f6;
    background: url(../../images/dataScreen-header-center-bg.png) no-repeat;
    background-size: 100% 100%;
    font-size: 35px;
    height: 80px;
  }
  .right {
    flex: 1;
    background: url(../../images/dataScreen-header-right-bg.png) no-repeat;
    background-size: 100% 100%;
    line-height: 40px;
    height: 40px;
    .rbtn {
      background: url(../../images/dataScreen-header-btn-bg-r.png) no-repeat;
      width: 160px;
      height: 40px;
      text-align: center;
      font-size: 20px;
      background-size: 100% 100%;
      display: inline-block;
      color: #29f0f6;
    }
    .time {
      color: #29f0f6;
      margin-left: 30px;
      font-size: 18px;
    }
  }
}
</style>
